package Practice;

import java.util.Arrays;
import java.util.Scanner;

public class ABC {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int number[] = new int[3];
        for (int i = 0; i < 3; i++) {
            number[i] = sc.nextInt();
        }

        String order = sc.next();


        Arrays.sort(number);
        for (int i=0;i<3;i++){
            char ch = order.charAt(i);//charAt（n）获取字符串的第n个字符
            if (ch=='A'){
                System.out.print(number[0]+" ");
            }
            if (ch=='B'){
                System.out.print(number[1]+" ");
            }
            if (ch=='C'){
                System.out.print(number[2]+" ");
            }
        }
    }
}
